package com.fin.zw.intelligentbot.controller;


import com.fin.zw.intelligentbot.annotation.CurrentUser;
import com.fin.zw.intelligentbot.enums.TaskStatus;
import com.fin.zw.intelligentbot.model.request.StatisticLogRequest;
import com.fin.zw.intelligentbot.model.response.StatisticCategoryResponse;
import com.fin.zw.intelligentbot.model.response.StatisticCustomerResponse;
import com.fin.zw.intelligentbot.model.session.SessionModel;
import com.fin.zw.intelligentbot.service.StatisticService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

@RestController
@RequestMapping("/statistics")
@Api(value = "首页统计管理", description = "首页统计管理")
public class StatisticsController {

    @Autowired
    private StatisticService statisticService;

    @GetMapping("/statisticsCustomer")
    @ApiOperation(value = "统计电话拨打状态(电话状态)", notes = "统计电话拨打状态(电话状态)")
    public ResponseEntity<List<StatisticCustomerResponse>> statisticsCustomer(StatisticLogRequest request,
                                                                              @ApiIgnore @CurrentUser SessionModel sessionModel) throws Exception {
        List<StatisticCustomerResponse> list = statisticService.statisticsCustomerByDate(request, sessionModel);
        return ResponseEntity.ok().body(list);
    }

    @GetMapping("/statisticsCustomerByTask")
    @ApiOperation(value = "统计电话拨打状态(电话状态)", notes = "统计电话拨打状态(电话状态)")
    public ResponseEntity<List<StatisticCustomerResponse>> statisticsCustomerByTask(StatisticLogRequest request,
                                                                                    @ApiIgnore @CurrentUser SessionModel sessionModel) {
        List<StatisticCustomerResponse> list = statisticService.statisticsCustomerByTask(request, sessionModel);
        return ResponseEntity.ok().body(list);
    }

    @GetMapping("/statisticsByTimeHour")
    @ApiOperation(value = "统计电话拨打状态(按照时间段统计)", notes = "统计电话拨打状态(按照时间段统计)")
    public ResponseEntity<List<StatisticCustomerResponse>> statisticsByTimeHour(@ApiIgnore @CurrentUser SessionModel sessionModel) {
        List<StatisticCustomerResponse> list = statisticService.statisticsByTimeHour(sessionModel);
        return ResponseEntity.ok().body(list);
    }

    @GetMapping("/statisticsCustomerBySce")
    @ApiOperation(value = "统计电话拨打状态(电话状态)", notes = "统计电话拨打状态(电话状态)")
    public ResponseEntity<List<StatisticCustomerResponse>> statisticsCustomerBySce(StatisticLogRequest request,
                                                                                   @ApiIgnore @CurrentUser SessionModel sessionModel) {
        List<StatisticCustomerResponse> list = statisticService.statisticsCustomerBySce(request, sessionModel);
        return ResponseEntity.ok().body(list);
    }


    @GetMapping("/getSceUnconnected")
    @ApiOperation(value = "统计电话拨打状态(电话状态)", notes = "统计电话拨打状态(电话状态)")
    public ResponseEntity<List<StatisticCategoryResponse>> getSceUnconnected(StatisticLogRequest request,
                                                                             @RequestParam("taskStatus") TaskStatus taskStatus,
                                                                             @ApiIgnore @CurrentUser SessionModel sessionModel) {
        List<StatisticCategoryResponse> list = statisticService.getSceUnconnected(request, taskStatus, sessionModel);
        return ResponseEntity.ok().body(list);
    }


    @GetMapping("/getTaskUnconnected")
    @ApiOperation(value = "统计电话拨打状态(电话状态)", notes = "统计电话拨打状态(电话状态)")
    public ResponseEntity<List<StatisticCategoryResponse>> getTaskUnconnected(StatisticLogRequest request,
                                                                              @RequestParam("taskStatus") TaskStatus taskStatus,
                                                                              @ApiIgnore @CurrentUser SessionModel sessionModel) {
        List<StatisticCategoryResponse> list = statisticService.getTaskUnconnected(request, taskStatus, sessionModel);
        return ResponseEntity.ok().body(list);
    }
}
